﻿using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;

/// <summary>
/// Editor创建撤销点工具
/// </summary>
public class VIPUndo {

    /// <summary>
    /// 创建一个撤消点
    /// </summary>
    public static void CreateUndo(string name, params Object[] objects)
    {
        if (objects != null && objects.Length > 0)
        {
            Undo.RecordObjects(objects, name);
            foreach (Object obj in objects)
            {
                if (obj == null) continue;
                EditorUtility.SetDirty(obj);
            }
        }
    }

    /// <summary>
    /// 创建一个创建对象的撤销点
    /// </summary>
    /// <param name="name"></param>
    /// <param name="obj"></param>
    public static void CreateObjectUndo(string name, Object obj) {
        if (obj != null)
        {
            Undo.RegisterCreatedObjectUndo(obj, name);
        }
    }

}
